package com.example.fanday.play.mvp.view;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.TextView;
import android.widget.Toast;

import com.example.fanday.play.R;
import com.example.fanday.play.mvp.base.BaseActivity;
import com.example.fanday.play.mvp.presenter.MainPresenterImpl;
import com.example.fanday.play.mvp.presenter.ipresenter.MainPresenter;
import com.example.fanday.play.mvp.view.iview.MainView;

import javax.inject.Inject;

public class MainActivity extends BaseActivity<MainPresenterImpl> implements MainView {

    @Inject
    public MainPresenterImpl mainPresenter;

    TextView textView;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView = (TextView) findViewById(R.id.test);
        presenter.loadData();
    }

    @Override
    protected MainPresenterImpl initInject() {
        activityComponent.inject(this);
        return mainPresenter;
    }


    @Override
    public void showToast(String msg) {
        Toast.makeText(this,"加载中。。。",Toast.LENGTH_LONG).show();
    }

    @Override
    public void showData(final String msg) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                textView.setText(msg);
            }
        });

    }
}
